//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for ServiceDiscovery
public struct ServiceDiscoveryErrorType: AWSErrorType {
    enum Code: String {
        case customHealthNotFound = "CustomHealthNotFound"
        case duplicateRequest = "DuplicateRequest"
        case instanceNotFound = "InstanceNotFound"
        case invalidInput = "InvalidInput"
        case namespaceAlreadyExists = "NamespaceAlreadyExists"
        case namespaceNotFound = "NamespaceNotFound"
        case operationNotFound = "OperationNotFound"
        case requestLimitExceeded = "RequestLimitExceeded"
        case resourceInUse = "ResourceInUse"
        case resourceLimitExceeded = "ResourceLimitExceeded"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceAlreadyExists = "ServiceAlreadyExists"
        case serviceNotFound = "ServiceNotFound"
        case tooManyTagsException = "TooManyTagsException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize ServiceDiscovery
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The health check for the instance that is specified by ServiceId and InstanceId is not a custom health check.
    public static var customHealthNotFound: Self { .init(.customHealthNotFound) }
    /// The operation is already in progress.
    public static var duplicateRequest: Self { .init(.duplicateRequest) }
    /// No instance exists with the specified ID, or the instance was recently registered, and information about the instance hasn't propagated yet.
    public static var instanceNotFound: Self { .init(.instanceNotFound) }
    /// One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.
    public static var invalidInput: Self { .init(.invalidInput) }
    /// The namespace that you're trying to create already exists.
    public static var namespaceAlreadyExists: Self { .init(.namespaceAlreadyExists) }
    /// No namespace exists with the specified ID.
    public static var namespaceNotFound: Self { .init(.namespaceNotFound) }
    /// No operation exists with the specified ID.
    public static var operationNotFound: Self { .init(.operationNotFound) }
    /// The operation can't be completed because you've reached the quota for the number of requests. For more information, see AWS Cloud Map API request throttling quota in the AWS Cloud Map Developer Guide.
    public static var requestLimitExceeded: Self { .init(.requestLimitExceeded) }
    /// The specified resource can't be deleted because it contains other resources. For example, you can't delete a service that contains any instances.
    public static var resourceInUse: Self { .init(.resourceInUse) }
    /// The resource can't be created because you've reached the quota on the number of resources.
    public static var resourceLimitExceeded: Self { .init(.resourceLimitExceeded) }
    /// The operation can't be completed because the resource was not found.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The service can't be created because a service with the same name already exists.
    public static var serviceAlreadyExists: Self { .init(.serviceAlreadyExists) }
    /// No service exists with the specified ID.
    public static var serviceNotFound: Self { .init(.serviceNotFound) }
    /// The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
}

extension ServiceDiscoveryErrorType: Equatable {
    public static func == (lhs: ServiceDiscoveryErrorType, rhs: ServiceDiscoveryErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension ServiceDiscoveryErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
